package com.qf.springcloud.controller;

import com.qf.springcloud.pojo.User;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

import java.util.Map;

@RestController
@RequestMapping("/producer")
public class ProducerController {

    @Value("${server.port}")
    private Integer port;

    @GetMapping("/test")
    public String test(){
        return "Hello Spring Cloud!! port:" + port;
    }



    @GetMapping("/test1/{id}")
    public String test1(@PathVariable String id){
        int i = 1 / 0;
        System.out.println("id:" + id);
        return id;
    }


    @PostMapping("/test2")
    public String test2(String name,Integer age){
        System.out.println("姓名：" + name + ",年龄:" + age);
        return "姓名：" + name + ",年龄:" + age;
    }


    @PostMapping("/test3")
    public String test3(@RequestBody User user){
        System.out.println(user);
        return user.toString();
    }

}
